package com.visiontech.volunteer_center.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
@RequestMapping("/role")
public class RoleController {

    @Autowired
    public UserController userController;

    @Autowired
    public AdministratorController administratorController;

    @RequestMapping("/user")
    public void chooseUser(@RequestParam("account") String account, @RequestParam("roleId") Integer roleId, @RequestParam("password") String password, HttpServletResponse response, HttpSession session) throws IOException {
        userController.verifyUser(account, roleId, password, response, session);
    }

    @RequestMapping("/administrator")
    public void chooseAdministrator(@RequestParam("account") String account, @RequestParam("roleId") Integer roleId,@RequestParam("password") String password, HttpServletResponse response, HttpSession session) throws IOException {
        administratorController.verifyUser(account, roleId, password, response, session);
    }
}
